﻿using System.Configuration;
using System.Data;
using System.Windows;

namespace WpfApp_Event
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public App()
        {
            //应用启动事件
            this.Startup += App_Startup;
            //应用退出事件
            this.Exit += App_Exit;
            //操作系统退出时候触发，提示是否组织操作系统关机
            this.SessionEnding += App_SessionEnding;
            //处理UI线程发生的异常信息
            this.DispatcherUnhandledException += App_DispatcherUnhandledException;
            //处理非UI线程发生的异常信息
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            //处理Task异常，之内当发生GC内存清理的时候才会触发
            TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
        }

        private void TaskScheduler_UnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e)
        {
            throw new NotImplementedException();
        }

        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            throw new NotImplementedException();
        }

        private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            throw new NotImplementedException();
        }

        private void App_SessionEnding(object sender, SessionEndingCancelEventArgs e)
        {
            e.Cancel = true;
        }

        private void App_Exit(object sender, ExitEventArgs e)
        {
            
        }

        private void App_Startup(object sender, StartupEventArgs e)
        {
            
        }
    }

}
